<!-- 为ref()标注类型 -->
<script lang="ts" setup>
import { ref } from 'vue'
import type { Ref } from 'vue'

/**
 * 1.推导出类型：Ref<number>
 */
const year = ref(2022)
console.log(year.value)

/**
 *2.指定类型(复杂类型)
 */
const month: Ref<string | number> = ref('12')
const day = ref<string | number>('31') //指定类型并给默认值

const n = ref<string>() //没有默认值会被推导为 string|undefined 类型
console.log(typeof n.value)
</script>

<template>
  <div>{{ year }}</div>
</template>

<style lang="scss" scoped></style>
